package com.zkingsoft.wechat;


import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.web.BaseAction;
import com.zkingsoft.bean.BizActivities;
import com.zkingsoft.bean.BizOrder;
import com.zkingsoft.bean.BizUser;
import com.zkingsoft.dao.BizCollageInfoDao;
import com.zkingsoft.dao.BizOrderDao;
import com.zkingsoft.redis.RedisUserLoginUtils;
import com.zkingsoft.service.BizActivitiesService;
import com.zkingsoft.service.BizCollageService;
import com.zkingsoft.service.BizOrderService;

/**
 * @description (订单)
 * @author 何明
 * @date 2018-05-23 00:08
 */
@Controller
@RequestMapping(value = "wxapi/order")
public class WxOrderAction extends BaseAction{

	@Autowired
	private BizActivitiesService bizActivitiesService;
	@Autowired
	private BizCollageService bizCollageService;
	@Autowired
	RedisUserLoginUtils redisUserLoginUtils;
	@Autowired
	private BizCollageInfoDao collageInfoDao;
	@Autowired
	private BizOrderService bizOrderService;
	@Autowired
	private BizOrderDao bizOrderDao;
	
	
	/**
	 * 查询所有订单
	 * detStatus: 1 待付款 、2 待使用、3 已使用
	 */   
   	@RequestMapping(value =  "/queryAll")
	public @ResponseBody AjaxResult queryAll(@RequestBody BizOrder bizOrder) {
   		BizUser loginUser = redisUserLoginUtils.getLoginUser();
   		bizOrder.setUserId(loginUser.getOpenId());
   		return new AjaxResult(AjaxResult.STATUS_SUCCESS,
   				bizOrderDao.selectAllOrder(bizOrder),bizOrderDao.selectAllOrderTotal(bizOrder));
   	}
	
	/**
	 * 查询订单详情
	 */   
   	@RequestMapping(value =  "/queryDetail/{orderId}")
	public @ResponseBody AjaxResult queryDetail(@PathVariable("orderId") String orderId) {
   		
   		return new AjaxResult(AjaxResult.STATUS_SUCCESS,Arrays.asList(bizOrderDao.queryDetail(orderId)));
   	}
   
}